import json
from ronglian_sms_sdk import SmsSDK

accId = '8aaf0708780055cd0178d3092c6a4f08'
accToken = '2789707cb34649e785abee8539469e59'
appId = '8aaf0708780055cd0178d3092d304f0e'


class SmsUtil:
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super().__new__(cls, *args, **kwargs)
            cls._instance.sms_sdk = SmsSDK(accId, accToken, appId)
        return cls._instance

    def send_message(self, mobile="15635661302", datas=("123456", "2"), tid="1"):
        resp = self.sms_sdk.sendMessage(tid, mobile, datas)
        resp_dict = json.loads(resp)
        if resp_dict.get("statusCode") == "000000":
            print("发送短信成功")
            return 0
        else:
            print("发送短信失败")
            return 1


if __name__ == '__main__':
    SmsUtil().send_message()
